package com.ruoyi.web.wx.controller;

import java.util.List;

import com.ruoyi.web.wx.entity.TrashAutonomousRecord;
import com.ruoyi.web.wx.service.ITrashAutonomousRecordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 自主投递记录 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-08-27
 */
@Controller
@RequestMapping("/system/trashAutonomousRecord")
public class TrashAutonomousRecordController extends BaseController
{
    private String prefix = "system/trashAutonomousRecord";
	
	@Autowired
	private ITrashAutonomousRecordService trashAutonomousRecordService;
	
	@RequiresPermissions("system:trashAutonomousRecord:view")
	@GetMapping()
	public String trashAutonomousRecord()
	{
	    return prefix + "/trashAutonomousRecord";
	}
	
	/**
	 * 查询自主投递记录列表
	 */
	@RequiresPermissions("system:trashAutonomousRecord:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TrashAutonomousRecord trashAutonomousRecord)
	{
		startPage();
        List<TrashAutonomousRecord> list = trashAutonomousRecordService.selectTrashAutonomousRecordList(trashAutonomousRecord);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出自主投递记录列表
	 */
	@RequiresPermissions("system:trashAutonomousRecord:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TrashAutonomousRecord trashAutonomousRecord)
    {
    	List<TrashAutonomousRecord> list = trashAutonomousRecordService.selectTrashAutonomousRecordList(trashAutonomousRecord);
        ExcelUtil<TrashAutonomousRecord> util = new ExcelUtil<TrashAutonomousRecord>(TrashAutonomousRecord.class);
        return util.exportExcel(list, "trashAutonomousRecord");
    }
	
	/**
	 * 新增自主投递记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存自主投递记录
	 */
	@RequiresPermissions("system:trashAutonomousRecord:add")
	@Log(title = "自主投递记录", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TrashAutonomousRecord trashAutonomousRecord)
	{		
		return toAjax(trashAutonomousRecordService.insertTrashAutonomousRecord(trashAutonomousRecord));
	}

	/**
	 * 修改自主投递记录
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		TrashAutonomousRecord trashAutonomousRecord = trashAutonomousRecordService.selectTrashAutonomousRecordById(id);
		mmap.put("trashAutonomousRecord", trashAutonomousRecord);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存自主投递记录
	 */
	@RequiresPermissions("system:trashAutonomousRecord:edit")
	@Log(title = "自主投递记录", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TrashAutonomousRecord trashAutonomousRecord)
	{		
		return toAjax(trashAutonomousRecordService.updateTrashAutonomousRecord(trashAutonomousRecord));
	}
	
	/**
	 * 删除自主投递记录
	 */
	@RequiresPermissions("system:trashAutonomousRecord:remove")
	@Log(title = "自主投递记录", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(trashAutonomousRecordService.deleteTrashAutonomousRecordByIds(ids));
	}
	
}
